<?php
namespace Store\Model;
use Think\Model;

class OrderLogModel extends Model
{
    
    protected $_auto = array(
        array('create_time', NOW_TIME, self::MODEL_INSERT),
        array('update_time', NOW_TIME, self::MODEL_BOTH),
    );

    public function insertLog($orderID, $orderState, $logMsg)
    {
        $auth = session('store_auth');
        $data = array();
        $data['order_id'] = $orderID;
        $data['order_sn'] = $orderID;
        $data['store_id'] = isset($auth['store_id']) ? $auth['store_id'] : 0;
        $data['member_id'] = isset($auth['user_id']) ? $auth['user_id'] : 0;
        $data['log_msg'] = $logMsg;
        $data['log_time'] = NOW_TIME;
        $data['log_role'] = isset($auth['group_id']) ? $auth['group_id'] : 0;
        $data['log_user'] = isset($auth['user_id']) ? $auth['user_id'] : 0;
        $data['log_orderstate'] = $orderState;
        $info = $this->create($data);
        if (! $info) {
            return false;
        }
        $result = $this->add($info);
        return $result;
    }
    
}
?>